/**
 * 
 */
package com.wsj.service.impl;

/******
 * 
 */
import java.util.List;

import org.springframework.dao.DataAccessException;

import com.wsj.dao.IBmFileTypeDao;
import com.wsj.dao.IBmResearchInstitutionDao;
import com.wsj.dao.IBmResearchReportTypeDao;
import com.wsj.dao.ICmQuotedCompanyDao;
import com.wsj.dao.IHomeSiteResearchReportFileUploadDao;
import com.wsj.service.IHomeSiteResearchReportFileUploadServ;
import com.wsj.util.exception.BusinessException;
import com.wsj.util.page.PageResultSet;
import com.wsj.web.form.researchReport.HomeSiteResearchReportFileUploadForm;
import com.wsj.web.subclass.displayBean.HomeSiteNews.HomeSiteUploadFileExtendBean;
import com.wsj.web.vo.homeSite.BmFileType;
import com.wsj.web.vo.homeSite.BmResearchInstitution;
import com.wsj.web.vo.homeSite.BmResearchReportType;
import com.wsj.web.vo.homeSite.CmQuotedCompany;
import com.wsj.web.vo.homeSite.HomeSiteUploadFile;

/**
 * @author fengbin  createTime:2009-7-25
 *
 */
public class HomeSiteResearchReportFileUploadServImpl implements
		IHomeSiteResearchReportFileUploadServ{
	
	
	/******
	 * 研究报告上传
	 */
	 private IHomeSiteResearchReportFileUploadDao homeSiteResearchReportFileUploadDao;
	 
	 /****
	  * 上市公司
	  */
	 private ICmQuotedCompanyDao  cmQuotedCompanyDao;
	 
	 /****
	  * 文件类型
	  */
	 private IBmFileTypeDao  bmFileTypeDao;
	 
	 /*****
	  * 研究机构
	  */
	 private IBmResearchInstitutionDao bmResearchInstitutionDao;
	 
	 /*****
	  * 研究报告类型
	  */
	 private IBmResearchReportTypeDao bmResearchReportTypeDao;
	 
	 

	public IBmFileTypeDao getBmFileTypeDao() {
		return bmFileTypeDao;
	}

	public void setBmFileTypeDao(IBmFileTypeDao bmFileTypeDao) {
		this.bmFileTypeDao = bmFileTypeDao;
	}

	public IBmResearchInstitutionDao getBmResearchInstitutionDao() {
		return bmResearchInstitutionDao;
	}

	public void setBmResearchInstitutionDao(
			IBmResearchInstitutionDao bmResearchInstitutionDao) {
		this.bmResearchInstitutionDao = bmResearchInstitutionDao;
	}

	public IBmResearchReportTypeDao getBmResearchReportTypeDao() {
		return bmResearchReportTypeDao;
	}

	public void setBmResearchReportTypeDao(
			IBmResearchReportTypeDao bmResearchReportTypeDao) {
		this.bmResearchReportTypeDao = bmResearchReportTypeDao;
	}

	public ICmQuotedCompanyDao getCmQuotedCompanyDao() {
		return cmQuotedCompanyDao;
	}

	public void setCmQuotedCompanyDao(ICmQuotedCompanyDao cmQuotedCompanyDao) {
		this.cmQuotedCompanyDao = cmQuotedCompanyDao;
	}

	public IHomeSiteResearchReportFileUploadDao getHomeSiteResearchReportFileUploadDao() {
		return homeSiteResearchReportFileUploadDao;
	}

	public void setHomeSiteResearchReportFileUploadDao(
			IHomeSiteResearchReportFileUploadDao homeSiteResearchReportFileUploadDao) {
		this.homeSiteResearchReportFileUploadDao = homeSiteResearchReportFileUploadDao;
	}

	/*******
	 * 添加研究报告
	 */
	public boolean addHomeSiteUploadFile(HomeSiteUploadFile homeSiteUploadFile) throws BusinessException {
		
		boolean isok=false;
		try {
			this.getHomeSiteResearchReportFileUploadDao().addHomeSiteUploadFile(homeSiteUploadFile);
			isok = true;
		} catch (DataAccessException e) {
			
			throw new BusinessException("添加研究报告",e);
		}
		
		return isok;
	}

	/*********
	 * 通过文件类型id,获取文件类型对象
	 */
	public BmFileType getBmFileTypeById(int bmFileTypeId) throws BusinessException {
		
		try {
			return this.getBmFileTypeDao().getBmFileTypeById(bmFileTypeId);
		} catch (DataAccessException e) {
			throw new BusinessException("通过文件类型id,获取文件类型对象,数据库异常",e);
		}
	}

	
	/********
	 * 通过研究机构id,获取研究机构对象
	 */
	public BmResearchInstitution getBmResearchInstitutionById(int bmResearchInstitutionId) throws BusinessException {
		
		
		 try {
			return this.getBmResearchInstitutionDao().getBmResearchInstitutionById(bmResearchInstitutionId);
		} catch (DataAccessException e) {
			throw new BusinessException("通过研究机构id,获取研究机构对象,数据库异常",e);
		}
		
	}

	/**********
	 * 获取所有研究机构
	 */
	public List<BmResearchInstitution> getBmResearchInstitutionList() throws BusinessException {
		
		try {
			return this.getBmResearchInstitutionDao().getBmResearchInstitutionList();
		} catch (DataAccessException e) {
			throw new BusinessException(" 获取所有研究机构,数据库异常",e);
		}
		
	}

	/*******
	 * 通过研究报告类型id,获取研究报告对象
	 */
	public BmResearchReportType getBmResearchReportTypeById(int bmResearchReportTypeId) throws BusinessException {
		
		try {
			return this.getBmResearchReportTypeDao().getBmResearchReportTypeById(bmResearchReportTypeId);
		} catch (BusinessException e) {
			throw new BusinessException(" 通过研究报告类型id,获取研究报告对象,数据库异常",e);
		}
		
	}

	/********
	 * 获取研究报告列表对象
	 */
	public List<BmResearchReportType> getBmResearchReportTypeList() throws BusinessException {
		
		return  this.getBmResearchReportTypeDao().getBmResearchReportTypeList();
	}

	
	/**********
	 * 通过上市公司id,获取上市公司对象
	 */
	public CmQuotedCompany getCmQuotedCompanyById(int cmQuotedCompanyId) throws BusinessException {
		
		try {
			return  this.getCmQuotedCompanyDao().getCmQuotedCompanyById(cmQuotedCompanyId);
		} catch (DataAccessException e) {
			throw new BusinessException("通过上市公司id,获取上市公司对象,数据库异常",e);
		}
	}

	/*********
	 * 获取文件类型列表
	 */
	public List<BmFileType> getFileTypeListList() throws BusinessException {
		
		try {
			return  this.getBmFileTypeDao().getFileTypeListList();
		} catch (DataAccessException e) {
			throw new BusinessException("获取文件类型列表,数据库异常",e);
		}
	}

	/*********
	 * 通过id,获取上传的研究报告对象
	 */
	public HomeSiteUploadFile getHomeSiteUploadFileById(Integer id) throws BusinessException {
		
		 try {
			return  this.getHomeSiteResearchReportFileUploadDao().getHomeSiteUploadFileById(id);
		} catch (DataAccessException e) {
			throw new BusinessException("通过id,获取上传的研究报告对象",e);
		}
	}

	
	/*************
	 * 通过股票数字代号,获取上市公司对象
	 */
	public CmQuotedCompany loadCmQuotedCompanyByStockNumId(String stockNumId) throws BusinessException {
		
		try {
			return this.getCmQuotedCompanyDao().loadCmQuotedCompanyByStockNumId(stockNumId);
		} catch (DataAccessException e) {
			throw new BusinessException("通过股票数字代号,获取上市公司对象 ,数据库异常",e);
		}
		
	}

    /**********
     *  搜索研究报告
     */
	public PageResultSet searchResearchReportList(HomeSiteResearchReportFileUploadForm homeSiteResearchReportFileUploadForm, int page, int pageSize) throws BusinessException {
		
		 try {
			return  this.getHomeSiteResearchReportFileUploadDao().searchResearchReportList(homeSiteResearchReportFileUploadForm,  page,  pageSize);
		} catch (DataAccessException e) {
			throw new BusinessException("搜索研究报告,数据库异常",e);
		}
	}

	
	/*********
	 * 更新研究报告
	 */
	public boolean updateHomeSiteUploadFile(HomeSiteUploadFile dbHomeSiteUploadFile) throws BusinessException {
		
		  boolean isok=false;
		  try {
			this.getHomeSiteResearchReportFileUploadDao().updateHomeSiteUploadFile(dbHomeSiteUploadFile);
			isok = true;
		} catch (DataAccessException e) {
			throw new BusinessException("更新研究报告,数据库异常",e);
		}
		
		return isok;
	}

	/***********
	 * 研究报告分页
	 */
	public PageResultSet getAllResearchReportList(int page, int pageSize) throws BusinessException {
		
		 try {
			return this.getHomeSiteResearchReportFileUploadDao().getAllResearchReportList(page,pageSize);
		} catch (DataAccessException e) {
			throw new BusinessException("获取前台研究报告,分页显示错误!",e);
		}
	}

	/*******
	 * 获取前几个研究报告
	 */
	public List<HomeSiteUploadFile> getResearchReportTop(int top) throws BusinessException {
		
		 try {
			return this.getHomeSiteResearchReportFileUploadDao().getResearchReportTop(top);
		} catch (DataAccessException e) {
			
			throw new BusinessException("获取前几个研究报告 error",e);
		}
	}

	
	

	

}
